/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.entity;

import com.qinyeit.serviceapp.entity.enums.*;
import lombok.Builder;
import lombok.experimental.Tolerate;

import javax.persistence.*;

/**
 * ClassName: Material <br/>
 * Function: 物品管理 <br/>
 * date: 2018-11-07 11:42:52 <br/>
 *
 * @author liuwenjin
 * @version  1.0
 * @since JDK 1.8
 */
@Builder
@Entity
@Table(name="materials")
public class Material extends MerchantGroupBaseEntity<Long> {

	private static final long serialVersionUID = 1L;

	// 物品编号 
    @Column(name="no", length = 300)
	private String no = null;

	// 物品名称 
    @Column(name="name", length = 300)
	private String name = null;

	// 物品拼音 
    @Column(name="pinyin", length = 300)
	private String pinyin = null;

	// 物品简码 
    @Column(name="spell", length = 300)
	private String spell = null;

	// 类别名称
	@ManyToOne
	@JoinColumn(name = "category_id")
	private MaterialCategory category = null;

	// 规格型号 
    @Column(name="goods_spec", length = 300)
	private String goodsSpec = null;

	// 库存单位 
    @Column(name="unit", length = 300)
	private String unit = null;

	// 最低库存 
    @Column(name="min_stock",scale=2)
	private Double minStock = null;

	// 最高库存 
    @Column(name="max_stock",scale=2)
	private Double maxStock = null;

	// 储存方式 
    @Column(name="store_mode", length = 300)
	@Enumerated(EnumType.STRING)
	private StoreMode storeMode = StoreMode.NORMALTEMPERATURE;

	// 最新采购单价 
    @Column(name="purchase_new_price",scale=2)
	private Double purchaseNewPrice = null;

	// 消耗单位 
    @Column(name="consume_unit", length = 300)
	private String consumeUnit = null;

	// 消耗单位换算值 
    @Column(name="consume_rates",scale=2)
	private Double consumeRates = null;

	// 成本卡标准价 
    @Column(name="order_price_bom",scale=2)
	private Double orderPriceBom = 0d;

	// 订货类型 
    @Column(name="order_type", length = 300)
	@Enumerated(EnumType.STRING)
	private OrderType orderType = OrderType.OTHER;

	// 盘点类型 
    @Column(name="stocktake_type", length = 300)
	@Enumerated(EnumType.STRING)
	private InventoryType stocktakeType = InventoryType.OTHER;

	// 状态 
    @Column(name="state", length = 300)
	@Enumerated(EnumType.STRING)
	private State state = State.NORMAL;

	//创建的时候生成 编辑的时候不变
	@Column(name="uuid", length = 300)
	private String uuid = "";

	//更新的时间戳 long
	@Column(name="update_timestamp")
	private Long updateTimestamp = null;

	//原料类型
	@Column(name = "material_type")
	@Enumerated(EnumType.STRING)
	private MaterialType materialType = MaterialType.MATERIAL;


	// 菜品库
	@Column(name="store_id")
	private Long storeId = null;


	//是否添加了加工关系
	@Column(name = "has_relation")
	private Boolean hasRelation = false;

	//商品条码 （零售和生鲜行业使用） 用逗号分隔 eg:,123,125,126,
	@Column(name="code")
	private String code = null;

//
	@Transient
	private String goodcode = "";

	@Transient
	private String[] goodcodes = null;


	public String getGoodcode() {
		return goodcode;
	}

	public void setGoodcode(String goodcode) {
		this.goodcode = goodcode;
	}

	public String[] getGoodcodes() {
		return goodcodes;
	}

	public void setGoodcodes(String[] goodcodes) {
		this.goodcodes = goodcodes;
	}

	@Tolerate
	public Material() {
		
	}
    @Tolerate
	public Material(Long id){
    	super.setId(id);
    }
	
	/**
	 * 获取物品编号
	 */
	public String getNo() {
		return this.no;
	}

    /**
     * 设置物品编号
     */
	public Material setNo(String no) {
		this.no = no;
		return this;
	}

	/**
	 * 获取物品名称
	 */
	public String getName() {
		return this.name;
	}

    /**
     * 设置物品名称
     */
	public Material setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取物品拼音
	 */
	public String getPinyin() {
		return this.pinyin;
	}

    /**
     * 设置物品拼音
     */
	public Material setPinyin(String pinyin) {
		this.pinyin = pinyin;
		return this;
	}

	/**
	 * 获取物品简码
	 */
	public String getSpell() {
		return this.spell;
	}

    /**
     * 设置物品简码
     */
	public Material setSpell(String spell) {
		this.spell = spell;
		return this;
	}

	public Long getStoreId() {
		return storeId;
	}

	public void setStoreId(Long storeId) {
		this.storeId = storeId;
	}

	/**
	 * 获取规格型号
	 */
	public String getGoodsSpec() {
		return this.goodsSpec;
	}

    /**
     * 设置规格型号
     */
	public Material setGoodsSpec(String goodsSpec) {
		this.goodsSpec = goodsSpec;
		return this;
	}

	/**
	 * 获取库存单位
	 */
	public String getUnit() {
		return this.unit;
	}

    /**
     * 设置库存单位
     */
	public Material setUnit(String unit) {
		this.unit = unit;
		return this;
	}

	/**
	 * 获取最低库存
	 */
	public Double getMinStock() {
		return this.minStock;
	}

    /**
     * 设置最低库存
     */
	public Material setMinStock(Double minStock) {
		this.minStock = minStock;
		return this;
	}

	/**
	 * 获取最高库存
	 */
	public Double getMaxStock() {
		return this.maxStock;
	}

    /**
     * 设置最高库存
     */
	public Material setMaxStock(Double maxStock) {
		this.maxStock = maxStock;
		return this;
	}


	/**
	 * 获取最新采购单价
	 */
	public Double getPurchaseNewPrice() {
		return this.purchaseNewPrice;
	}

    /**
     * 设置最新采购单价
     */
	public Material setPurchaseNewPrice(Double purchaseNewPrice) {
		this.purchaseNewPrice = purchaseNewPrice;
		return this;
	}

	/**
	 * 获取消耗单位
	 */
	public String getConsumeUnit() {
		return this.consumeUnit;
	}

    /**
     * 设置消耗单位
     */
	public Material setConsumeUnit(String consumeUnit) {
		this.consumeUnit = consumeUnit;
		return this;
	}

	/**
	 * 获取消耗单位换算值
	 */
	public Double getConsumeRates() {
		return this.consumeRates;
	}

    /**
     * 设置消耗单位换算值
     */
	public Material setConsumeRates(Double consumeRates) {
		this.consumeRates = consumeRates;
		return this;
	}

	/**
	 * 获取成本卡标准价
	 */
	public Double getOrderPriceBom() {
		return this.orderPriceBom;
	}

    /**
     * 设置成本卡标准价
     */
	public Material setOrderPriceBom(Double orderPriceBom) {
		this.orderPriceBom = orderPriceBom;
		return this;
	}

	public MaterialCategory getCategory() {
		return category;
	}

	public void setCategory(MaterialCategory category) {
		this.category = category;
	}

	public StoreMode getStoreMode() {
		return storeMode;
	}

	public void setStoreMode(StoreMode storeMode) {
		this.storeMode = storeMode;
	}

	public OrderType getOrderType() {
		return orderType;
	}

	public void setOrderType(OrderType orderType) {
		this.orderType = orderType;
	}

	public InventoryType getStocktakeType() {
		return stocktakeType;
	}

	public void setStocktakeType(InventoryType stocktakeType) {
		this.stocktakeType = stocktakeType;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Long getUpdateTimestamp() {
		return updateTimestamp;
	}

	public void setUpdateTimestamp(Long updateTimestamp) {
		this.updateTimestamp = updateTimestamp;
	}

	public MaterialType getMaterialType() {
		return materialType;
	}

	public void setMaterialType(MaterialType materialType) {
		this.materialType = materialType;
	}

	public Boolean getHasRelation() {
		return hasRelation;
	}

	public void setHasRelation(Boolean hasRelation) {
		this.hasRelation = hasRelation;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}
